#include "TemplateMethodLibrary.h"
#include <QDebug>

#include "UI/ModRun/Output/FactoryOutput.h"


TemplateMethodLibrary::TemplateMethodLibrary()
{

}

TemplateMethodLibrary::~TemplateMethodLibrary()
{

}

//步骤1;
void TemplateMethodLibrary::Step1()
{
    QString strOutput = "TemplateMethodLibrary::Step1";
    qDebug() << strOutput;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutput };
        pOutPut->OutPut(outList);
    }
}

//步骤2;
//virtual bool Step2() = 0;

//步骤3;
void TemplateMethodLibrary::Step3()
{
    QString strOutput = "TemplateMethodLibrary::Step3";
    qDebug() << strOutput;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutput };
        pOutPut->OutPut(outList);
    }
}

//步骤4;
//virtual void Step4() = 0;

//步骤5;
void TemplateMethodLibrary::Step5()
{
    QString strOutput = "TemplateMethodLibrary::Step5";
    qDebug() << strOutput;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutput };
        pOutPut->OutPut(outList);
    }
}

//稳定的 templateMethod;
void TemplateMethodLibrary::Run()
{
    QString strOutputStart = "TemplateMethodLibrary::组装过程调用start";
    qDebug() << strOutputStart;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutputStart };
        pOutPut->OutPut(outList);
    }

    Step1();

	if (Step2())
	{
		Step3();
	}

	for (size_t i = 0; i < 4; i++)
	{
		Step4();
	}
	
	Step5();

    QString strOutputEnd = "TemplateMethodLibrary::组装过程调用end";
    qDebug() << strOutputEnd;
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutputEnd };
        pOutPut->OutPut(outList);
    }
}
